package com.yunlankeji.stemcells.activity.home;

import androidx.annotation.NonNull;
import androidx.appcompat.app.AppCompatActivity;
import androidx.fragment.app.Fragment;
import androidx.viewpager2.widget.ViewPager2;

import android.os.Bundle;
import android.view.View;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.google.android.material.tabs.TabLayout;
import com.google.android.material.tabs.TabLayoutMediator;
import com.yunlankeji.ganxibaozhijia.R;
import com.yunlankeji.stemcells.adapter.MyAdapter;
import com.yunlankeji.stemcells.fragemt.fragment_mine_personal_space_fans;
import com.yunlankeji.stemcells.fragemt.fragment_mine_personal_space_follow;
import com.yunlankeji.stemcells.fragemt.home.fragment_home_organization_expert;
import com.yunlankeji.stemcells.fragemt.home.fragment_home_organization_goods;
import com.yunlankeji.stemcells.fragemt.home.fragment_home_organization_home;
import com.yunlankeji.stemcells.fragemt.home.fragment_home_organization_information;
import com.yunlankeji.stemcells.fragemt.home.fragment_home_organization_video;

import java.util.ArrayList;
import java.util.List;

import butterknife.BindView;
import butterknife.ButterKnife;

public class Home_organization_detialActivity extends AppCompatActivity {
    @BindView(R.id.tv_organization_detail_title)
    TextView tv_organization_detail_title;
    @BindView(R.id.tv_organization_detail_name)
    TextView tv_organization_detail_name;
    @BindView(R.id.tv_organization_detail_fans)
    TextView tv_organization_detail_fans;
    @BindView(R.id.iv_organization_detail)
    ImageView iv_organization_detail;
    @BindView(R.id.lt_home_organization_detial_return)
    LinearLayout lt_home_organization_detial_return;

    private TabLayout tb_home_organization_detial;
    private ViewPager2 vg_home_organization_detial;

    List<String> titles=new ArrayList<>();
    List<Fragment> fragments=new ArrayList<>();

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_home_organization_detial);
        ButterKnife.bind(this);

        tb_home_organization_detial = findViewById(R.id.tb_home_organization_detial);

        vg_home_organization_detial = findViewById(R.id.vg_home_organization_detial);

        tv_organization_detail_title = findViewById(R.id.tv_organization_detail_title);

        String title = getIntent().getStringExtra("title");
        tv_organization_detail_title.setText(title);

        String name = getIntent().getStringExtra("name");
        tv_organization_detail_name.setText(name);

        String fans = getIntent().getStringExtra("fans");
        tv_organization_detail_fans.setText(fans);

        /*String picture = getIntent().getStringExtra("picture");
        iv_organization_detail.setImageResource(picture);*/


        lt_home_organization_detial_return.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                finish();
            }
        });



        //添加标题
        titles.add("首页");
        titles.add("专家");
        titles.add("视频");
        titles.add("资讯");
        titles.add("商品");


        //添加Fragment进去
        fragments.add(new fragment_home_organization_home());
        fragments.add(new fragment_home_organization_expert());
        fragments.add(new fragment_home_organization_video());
        fragments.add(new fragment_home_organization_information());
        fragments.add(new fragment_home_organization_goods());

        //实例化适配器
        MyAdapter myAdapter = new MyAdapter(getSupportFragmentManager(), getLifecycle(), fragments);
        //设置适配器
        vg_home_organization_detial.setAdapter(myAdapter);
        //TabLayout和Viewpager2进行关联
        new TabLayoutMediator(tb_home_organization_detial, vg_home_organization_detial, new TabLayoutMediator.TabConfigurationStrategy() {
            @Override
            public void onConfigureTab(@NonNull TabLayout.Tab tab, int position) {
                tab.setText(titles.get(position));
            }
        }).attach();




    }
}